package com.programbookstore.controller;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.programbookstore.model.Book;
import com.programbookstore.service.BookService;





@Controller
public class BookController {
	@Autowired
	private BookService bookservice;

//	private static final Logger logger = Logger.getLogger(BookController.class);
	@RequestMapping(value ={"/"},method=RequestMethod.GET)
	public String List(Model model) {
//		//logs debug message
//				if(logger.isDebugEnabled()){
//					logger.debug("getWelcome is executed!");
//				}
//		 
//				//logs exception
//				logger.error("This is Error message", new Exception("Testing"));
		List<Book> bookList=  bookservice.ListBook();
			model.addAttribute("bookList", bookList);
		
		
		return "bookstoreindex";
	}
	
	@RequestMapping(value ={"/add"},method=RequestMethod.GET)
	public String AddBookStore(Model model) {
//		//logs debug message
//				if(logger.isDebugEnabled()){
//					logger.debug("getWelcome is executed!");
//				}
//		 
//				//logs exception
//				logger.error("This is Error message", new Exception("Testing"));
		
		
		
		return "bookstoreadd";
	}
	
}
